/*
    文件同步
*/
const fs = require('fs-extra');
const fileSync = function(query){
    return new Promise((resolve, reject) => {
        try { 
            if(!fs.existsSync(query.past)||!fs.existsSync(query.new)){
                reject({
                    code:"1",
                    msg:`文件同步失败`
                });
                return
            };
            fs.copy(query.past, query.new,(err, result) => {
                if (err) {
                    reject({
                        code:"1",
                        msg:`文件同步失败`
                    });
                } else {
                    resolve({
                        code:"0",
                        msg:`文件同步成功`
                    });
                }
            });
        } catch (err) {
            reject({
                code:"1",
                msg:`文件同步失败`
            });
        };
    });
};
module.exports=fileSync;
